package com.llkj.qingnianguoxue.music;

import android.Manifest;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.media.MediaPlayer;
import android.media.MediaRecorder;
import android.os.Bundle;
import android.os.IBinder;
import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.SeekBar;
import android.widget.TextView;

import com.jm.chat.pickerimage.utils.StringUtil;
import com.llkj.qingnianguoxue.R;
import com.llkj.qingnianguoxue.base.BaseActivity;
import com.llkj.qingnianguoxue.bean.Response;
import com.llkj.qingnianguoxue.db.LocalMusicBean;
import com.llkj.qingnianguoxue.http.HttpMethod;
import com.llkj.qingnianguoxue.lrcview.LrcView;
import com.llkj.qingnianguoxue.playservice.Music;
import com.llkj.qingnianguoxue.playservice.OnlineMusic;
import com.llkj.qingnianguoxue.playservice.PlayOnlineMusic;
import com.llkj.qingnianguoxue.playservice.SecondPlayService;
import com.llkj.qingnianguoxue.playservice.SystemUtils;
import com.llkj.qingnianguoxue.util.DialogUtil;
import com.llkj.qingnianguoxue.util.DisplayUtil;
import com.llkj.qingnianguoxue.util.FileOperation;
import com.llkj.qingnianguoxue.util.GsonUtil;
import com.llkj.qingnianguoxue.util.ImageLoadingUtil;
import com.llkj.qingnianguoxue.util.MyShare;
import com.llkj.qingnianguoxue.util.SelectPictureUtil;
import com.llkj.qingnianguoxue.util.StringUtils;
import com.llkj.qingnianguoxue.util.ToastUtil;
import com.llkj.qingnianguoxue.util.Utils;
import com.llkj.qingnianguoxue.util.audiorecorder.AudioRecorder;
import com.tbruyelle.rxpermissions.RxPermissions;

import java.io.File;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import rx.functions.Action1;

import static com.llkj.qingnianguoxue.http.HttpMethod.HTTP_KOJI_PRESERVATION;


public class RecordMusicActivity extends BaseActivity implements SelectPictureUtil.SelectPictureResultCallback,DialogUtil.ClickOptionListener,MyShare.ShareResultCallback{

    private final int REQUEST_COMPLETE_CODE = 9790;
    @BindView(R.id.music_title)
    View titleView;//
    @BindView(R.id.ivMusicBg)
    protected ImageView mIvMusicBg;//背景
    @BindView(R.id.iv_music_corver)
    protected ImageView mIvMusicCorver;//封面
    @BindView(R.id.tv_music_name)
    protected TextView mTvMusicName;//音乐名
    @BindView(R.id.tv_count)
    protected TextView mTvCount;//听过人数
    @BindView(R.id.tvPlayerCurrentTime)
    protected TextView mTvCurrentTime;//当前播放时间
    @BindView(R.id.tvPlayerDuration)
    protected TextView mTvPlayerDuration;//总播放时长
    @BindView(R.id.sbPlayerProgress)
    protected SeekBar mSeekBar;//播放进度
    @BindView(R.id.lrc_view_full)
    protected LrcView mLrcView;//歌词显示
    @BindView(R.id.ll_original)
    LinearLayout llOriginal;//原唱
    @BindView(R.id.tv_original_title)
    TextView tvOriginal;
    private int mPlayDuration,mLastProgress;//播放时长,播放进度

    private AudioRecorder mAudioRecorder;
    private File mAudioFile,mLrcFile;//录制文件，歌词文件
    private int mRecordState = -1;//-1未开始，1录制中

    private String mMusicId;//伴奏id
    private String mMusicCorverUrl;//伴奏音乐封面图片
    private String mMusicName;//伴奏音乐名称
    private String mCountSing;//演唱人数
    private String mMusicBgPath;//背景图片
    private String mMusicUrl;//伴奏音乐
    private String mOriginalMusicUrl;//原唱音乐
    private String mMusicLrcUrl;//歌词url
    private String mArtistName;//作者
    private String mMusicPath;//伴奏音乐，本地下载路径
    private boolean isPermissions;//请求存储，录音权限
    private SecondPlayService playService;
    private int mPlayProgress;
    private int mDownloadOriginalState,mDownloadBgState;//下载原唱文件状态，下载伴奏文件状态；0下载中，1下载完成，2下载失败
    private int mPictureShowCount;//选择相册。拍照弹框次数
    private SelectPictureUtil mSelectPictureUtil;//选择图片
    private boolean isPublishSing = false,isSaveLocal = false;//是否发布了音乐，是否保存本地数据库了
    private String mLinkUrl;//分享录制的链接
    private int mPublishType;//哪种发布方式，1保存按钮发布，2分享按钮，3保存展示到个人主页
    private String mPublishSingId;//分享时用到的发布音乐id

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_record_music);

        ButterKnife.bind(this);
        new RxPermissions(this)
                .request(Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.RECORD_AUDIO, Manifest.permission.CAMERA)
                .subscribe(new Action1<Boolean>() {
                    @Override
                    public void call(Boolean aBoolean) {
                        isPermissions = aBoolean;
                    }
                });

        getIntentData();

        initView();
        initAudioRecorder();
        initListener();

        loadWaitDialog();
        mHandler.postDelayed(new Runnable() {
            @Override
            public void run() {
                bindService();
            }
        }, 2000);
    }

    private void initLrcData(){
        if(StringUtils.isEmpty(mArtistName)){
            mArtistName = mMusicId;
        }
        OnlineMusic onlineMusic = new OnlineMusic();
        //这两个字段是用于处理歌词文件名的
        onlineMusic.setArtist_name("lrc");
        onlineMusic.setTitle(mMusicId);
        //这个是下载歌词的链接
        onlineMusic.setLrclink(mMusicLrcUrl);
        onlineMusic.setMusicUrl(mMusicUrl);
        onlineMusic.setOrgMusicUrl(mOriginalMusicUrl);
        play(onlineMusic);
    }

    private void initView(){
        setTitle(mMusicName, true, TITLE_TYPE_IMG, R.drawable.icon_back_white, false,-1,-1);
//        if(Build.VERSION.SDK_INT>19){
//            RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) titleView.getLayoutParams();
//            params.topMargin = DisplayUtil.dip2px(this,20);
//        }
//        systemBarTintManager.setStatusBarTintColor(ContextCompat.getColor(this, R.color.transparent));
        initStatusbar(TSATUSBAR_TYPE_BLACK_TEXT,titleView,R.color.transparent);
        rlTitle.setBackgroundColor(ContextCompat.getColor(this, R.color.transparent));
        titleLineBottom.setVisibility(View.GONE);
        tvTitle.setTextColor(ContextCompat.getColor(this, R.color.white));

        ImageLoadingUtil.loadImgGlideRoundCenterCrop(mIvMusicCorver,mMusicCorverUrl);
        mTvMusicName.setText(mMusicName);
        mTvCount.setText(mCountSing+"人唱过");
    }

    private void initAudioRecorder(){
        mAudioRecorder = AudioRecorder.getInstance();
        String path = Utils.getAppRecordDir(this)+"record_"+System.currentTimeMillis()+".mp4";
        mAudioFile = new File(path);
        Utils.createNewFile(mAudioFile);
        mAudioRecorder.prepareRecord(MediaRecorder.AudioSource.MIC,
                MediaRecorder.OutputFormat.MPEG_4, MediaRecorder.AudioEncoder.AAC,
                mAudioFile);
    }

    private void initListener(){
        mSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
            @Override
            public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
                //进度变化调用
                Log.e("Log","===onProgressChanged()=="+progress);
            }

            @Override
            public void onStartTrackingTouch(SeekBar seekBar) {
                //开始拖动调用
                Log.e("Log","===onStartTrackingTouch()=="+seekBar.getProgress());
            }

            @Override
            public void onStopTrackingTouch(SeekBar seekBar) {
                //拖动停止调用
                Log.e("Log","===onStopTrackingTouch()=="+seekBar.getProgress());
                int progress = mPlayDuration*seekBar.getProgress()/100;
                getPlayService().seekTo(progress);
                playService.seekTo(progress);
                mLrcView.updateTime(progress);
                mLrcView.loadLrc(mLrcFile);
            }
        });
    }

    @OnClick({R.id.ll_original, R.id.ll_volume, R.id.iv_play, R.id.ll_reset, R.id.ll_complete,
            R.id.ll_repeat,R.id.tvSave,R.id.ll_share})
    public void onClick(View v){
        switch (v.getId()){
            case R.id.ll_original://原唱
                if(mDownloadOriginalState == 2){
                    ToastUtil.makeLongText(RecordMusicActivity.this,"原唱文件下载失败");
                    return;
                }
                if(!StringUtil.isEmpty(mMusicPath)) {
                    llOriginal.setSelected(!llOriginal.isSelected());
                    if(llOriginal.isSelected()){
                        tvOriginal.setText("伴唱");
                    }else{
                        tvOriginal.setText("原唱");
                    }

                    if (!llOriginal.isSelected()) {//处理背景音乐
                        getPlayService().seekTo(mLastProgress);
                    } else {//处理原唱
                        if (playService != null) {
                            playService.seekTo(mLastProgress);
                        }
                    }
                    if (playService != null) {
                        playService.playPause();//处理原唱
                        getPlayService().playPause();//处理背景音乐
                    }
                }
                break;
            case R.id.ll_volume://升降调
                DialogUtil.showVolumeControl(this);
                break;
            case R.id.iv_play://开始录制
//                startPlay(mMusicPath);
                startRecord();
                break;
            case R.id.ll_reset://录制重唱
                stopRecord();
                resetRecord();
                startRecord();
//                startPlay(mMusicPath);
                break;
            case R.id.ll_complete://结束
                recordComplete();
                break;
            case R.id.ll_repeat://录制完成再重唱
                mPictureShowCount = 0;//重置图片选择弹框次数
                isSaveLocal = false;//重唱则设置为未保存
                isPublishSing = false;//重置是否发布
                //隐藏录制底部按钮
                findViewById(R.id.ll_bottom).setVisibility(View.VISIBLE);
                //显示完成底部按钮
                findViewById(R.id.ll_complete_bottom).setVisibility(View.GONE);
                resetRecord();
                startRecord();
                break;
            case R.id.tvSave://保存
                if(mPictureShowCount<1){
                    showPhotoPictureDialog();
                }else{
                    //分享至个人主页
                    if(isPublishSing){
                        ToastUtil.makeLongText(this,"作品已发布完成");
                    }else{
                        DialogUtil.dialogConfirm(this, "是否将作品展示在个\n人主页上?", null, "暂不展示", "立即展示", new DialogUtil.DialogClickListener() {
                            @Override
                            public void dialogClick(int type) {
                                if(type==1){//立即展示
                                    mPublishType = 3;
                                    publishIsShowPersonal("1");
                                }else{
                                    mPublishType = 1;
                                    publishIsShowPersonal("2");
                                }
                            }
                        }).show();
                    }
                    //保存本地数据库
                    saveRecordData();
                }
                break;
            case R.id.ll_share://录制完成分享
                if(mPictureShowCount<1){
                    showPhotoPictureDialog();
                }else{
                    if(!StringUtil.isEmpty(mPublishSingId)){
                        mLinkUrl = String.format(HttpMethod.SHARE_USERKOJI,mPublishSingId);
                        //分享弹框
                        DialogUtil.showShareMusicDialog(this,this);
                    }else{
                        mPublishType = 2;
                        publishIsShowPersonal("2");
                    }
                }
                break;
        }
    }

    /**
     * 预加载音乐
     * @param musicUrl
     */
    private void startPlay(String musicUrl){
//        loadWaitDialog();
        if(!StringUtil.isEmpty(musicUrl)){
            mRecordState = -1;
            Music music = new Music();
            music.setType(Music.Type.LOCAL);
            music.setPath(musicUrl);
            getPlayService().play(music);//开始播放音乐
            getPlayService().setOnPlayEventListener(this);
            resetRecord();
        }
    }

    /**
     * 重置音乐播放和歌词
     */
    private void resetRecord(){
        mLastProgress = 0;
        mTvCurrentTime.setText(formatTime(0));
        mLrcView.updateTime(0);
        mLrcView.loadLrc(mLrcFile);
        getPlayService().seekTo(0);
        mSeekBar.setProgress(0);
    }

    /**
     * 开始播放音乐，并录制
     */
    private void startRecord(){
        if(mAudioRecorder!=null && mRecordState==-1){
            getPlayService().playPause();
            mRecordState = 1;
            mAudioRecorder.startRecord();
        }
    }

    /**
     * 停止录制
     */
    private void stopRecord(){
        try {
            getPlayService().playPause();
        }catch (Exception e){}
        if(mAudioRecorder!=null){
            // 停止录制
            mAudioRecorder.stopRecord();
            mRecordState = -1;
        }
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if(resultCode==RESULT_OK) {
            if (requestCode == REQUEST_COMPLETE_CODE) {
                String result = data.getStringExtra("result");
                if ("repeat".equals(result)) {//重唱
                    stopRecord();
                    startPlay(mMusicUrl);
                } else if ("finish".equals(result)) {//完成
                    finish();
                }
            }
            if(mSelectPictureUtil!=null){
                mSelectPictureUtil.onActivityResult(requestCode, resultCode, data);
            }
        }
    }

    /**
     * 完成录制
     */
    public void recordComplete(){
        stopRecord();
        //隐藏录制底部按钮
        findViewById(R.id.ll_bottom).setVisibility(View.GONE);
        //显示完成底部按钮
        findViewById(R.id.ll_complete_bottom).setVisibility(View.VISIBLE);
        isPublishSing = false;
        mPublishSingId = null;
//        boolean exists = mAudioFile.exists();
//        if(mAudioFile !=null && !StringUtil.isEmpty(mMusicPath)){
//            Bundle bundle = new Bundle();
//            bundle.putString("recordPath",mAudioFile.getPath());//录制文件地址
//            bundle.putString("musicId",mMusicId);//伴奏id
//            bundle.putString("musicCoverUrl",mMusicCorverUrl);//伴奏音乐封面图片
//            bundle.putString("musicName",mMusicName);//伴奏音乐名称
//            bundle.putString("countSing",mCountSing);//演唱人数
////            bundle.putString("musicBgPath",mMusicBgPath);//背景图片地址
//            bundle.putString("musicUrl",mMusicUrl);//伴奏音乐url
//            bundle.putString("musicOriginalUrl",mOriginalMusicUrl);//原唱音乐url
//            bundle.putString("musicLrcUrl",mMusicLrcUrl);//歌词url
//            startActivityForResult(RecordCompleteActivity.class,bundle,REQUEST_COMPLETE_CODE);
//        }
    }

    private void play(OnlineMusic onlineMusic) {
        new PlayOnlineMusic(this, onlineMusic) {
            @Override
            public void onPrepare() {}

            @Override
            public void onExecuteSuccess(Music music) {
                dismissWaitDialog();
            }

            @Override
            public void onExecuteFail(Exception e) {}
        }.setRefuseMobileNetListener(new PlayOnlineMusic.RefuseUserMobileNEtListener() {
            @Override
            public void refuseMobileNet() {
                dismissWaitDialog();
                myFinish();
            }
        }).setDownloadListener(new PlayOnlineMusic.DownloadFileListener() {
            @Override
            public void downloadFileListener(int type, int state, float progress,File file) {
                switch (type){
                    case 0:
                        if(state==1){//歌词下载成
                            mLrcFile = file;
                            mLrcView.loadLrc(file);
                        }else if(state==2 && progress<2){//歌词下载中
                            mLrcView.setLabel("正在下载歌词...");
                        }else if(state==3){
                            mLrcView.setLabel("暂无歌词");
                        }
                        break;
                    case 2://原唱文件
                        if(state==1){
                            mDownloadOriginalState = 1;
                            Music music = new Music();
                            music.setPath(file.getAbsolutePath());
                            if(playService!=null){
                                playService.play(music);
                            }
                        }else if(state==3){
                            mDownloadOriginalState = 2;
                            ToastUtil.makeLongText(RecordMusicActivity.this,"原唱文件下载失败");
                            Log.e("Log","=原唱文件下载失败==");
                        }

                        break;
                    case 1://伴奏音乐文件
                        if(state==1) {
                            mMusicPath =file.getAbsolutePath();
                            mDownloadBgState = 1;
                            startPlay(mMusicPath);
//                            getPlayService().playPause();
                        }else if(state==3){
                            mDownloadBgState = 2;
                            ToastUtil.makeLongText(RecordMusicActivity.this,"伴奏音乐下载失败");
                            Log.e("Log","=伴奏音乐下载失败==");
                        }

                        break;
                }
            }
        }).execute();
    }

    /**
     * 更新播放进度
     */
    @Override
    public void onPublish(int progress) {
        super.onPublish(progress);

        if(mPlayDuration<=0){
            mPlayDuration = getPlayService().getMediaPlayer().getDuration();
            mTvPlayerDuration.setText(formatTime(mPlayDuration));
        }

        if(mPlayDuration>0){
            mPlayProgress = progress*100/mPlayDuration;
            mSeekBar.setProgress(mPlayProgress);
        }

        Log.e("Log","====getPlayService()==progress="+progress+",duration="+getPlayService().getMediaPlayer().getDuration());

        mLastProgress = progress;
        //更新当前播放时间
//        if(progress-mLastProgress>=1000){
            mTvCurrentTime.setText(formatTime(progress));
            mLrcView.updateTime(progress);
//        }

        if(mPlayProgress==100){//播放完成
            recordComplete();
        }
    }

    @Override
    public void onPrepared(MediaPlayer mp) {
        super.onPrepared(mp);
        mPlayDuration = mp.getDuration();
        mTvPlayerDuration.setText(formatTime(mPlayDuration));
    }

    @Override
    public void onBufferingUpdate(int percent) {
        mSeekBar.setSecondaryProgress(mSeekBar.getMax() * 100 / percent);
    }

    @Override
    protected void onDestroy() {
        try {
            unbindService(mPlaySecondConnection);
            playService.stop();

        }catch (Exception e){}
        super.onDestroy();
    }

    private PlaySecondConnection mPlaySecondConnection;
    private void bindService() {
        Intent intent = new Intent();
        intent.setClass(this, SecondPlayService.class);
        mPlaySecondConnection = new PlaySecondConnection();
        bindService(intent, mPlaySecondConnection, Context.BIND_AUTO_CREATE);
    }

    private class PlaySecondConnection implements ServiceConnection {
        @Override
        public void onServiceConnected(ComponentName name, IBinder service) {
            playService = ((SecondPlayService.PlayBinder) service).getService();
            initLrcData();
            playService.setOnPlayEventListener(RecordMusicActivity.this);
        }

        @Override
        public void onServiceDisconnected(ComponentName name) {}
    }

    private String formatTime(long time) {
        return SystemUtils.formatTime("mm:ss", time);
    }


    /**
     * 拍照相册弹框
     */
    private void showPhotoPictureDialog(){
        if(mSelectPictureUtil==null){
            mSelectPictureUtil = new SelectPictureUtil(this,this);
            mSelectPictureUtil.setCropWidthHeight(DisplayUtil.getDensityWdith(this),DisplayUtil.getDensityHeight(this));
        }
        mPictureShowCount++;
        DialogUtil.showPhotoPictureDialog(this, new DialogUtil.DialogClickListener() {
            @Override
            public void dialogClick(int type) {
                switch (type) {
                    case 1://拍照
                        if (isPermissions) {
                            mSelectPictureUtil.takePhoto();
                        } else {
                            ToastUtil.makeLongText(RecordMusicActivity.this, getResources().getString(R.string.permission_camera));
                        }
                        break;
                    case 2://相册
                        mSelectPictureUtil.album();
                        break;
                    case 4://取消

                        break;
                }
            }
        }).show();
    }

    @Override
    public void onCropResult(File file) {
        mMusicBgPath = file.getAbsolutePath();
        ImageLoadingUtil.loadingUrl(mIvMusicBg, mMusicBgPath);
    }

    /**
     * 录制完成，保存本地
     */
    private void saveRecordData(){
        if(isSaveLocal){//已保存则不在保存
            return;
        }
        LocalMusicBean musicBean = new LocalMusicBean();
        musicBean.setRecordMusicPath(mAudioFile.getPath());//录制本地路径
        musicBean.setMusicId(mMusicId);//伴奏id
        musicBean.setMusicCorverUrl(mMusicCorverUrl);//伴奏音乐封面图片
        musicBean.setMusicName(mMusicName);//伴奏音乐名称
        musicBean.setCountSing(mCountSing);//演唱人数
        saveDefaultPic();
        musicBean.setMusicBgPath(mMusicBgPath);//背景图片
        musicBean.setMusicUrl(mMusicUrl);//伴奏音乐
        musicBean.setOriginalMusicUrl(mOriginalMusicUrl);//原唱音乐
        musicBean.setMusicLrcUrl(mMusicLrcUrl);//歌词url
        if (musicBean.save()) {
            isSaveLocal = true;
            Log.e("Log","===数据库存储成功");
        } else {
            //存储失败
            Log.e("Log","===数据库存储失败");
        }
    }

    //保存默认图片
    private void saveDefaultPic(){
        if(StringUtil.isEmpty(mMusicBgPath)){
            try {
                Bitmap bitmap = BitmapFactory.decodeResource(getResources(),R.drawable.icon_record_bg);;
                File file = FileOperation.saveBgFile(this, bitmap);
                mMusicBgPath = file.getAbsolutePath();
                bitmap.recycle();
                bitmap= null;
            }catch (Exception e){}
        }
    }

    @Override
    public void clickOptionResopnse(int option) {
        //直接调起三方分享
        String content = mCountSing+"人演唱过";
        mLinkUrl = String.format(HttpMethod.SHARE_USERKOJI,mMusicId);
        DialogUtil.shareParams(this,option,mMusicName,content,mMusicCorverUrl,mLinkUrl,this);
    }

    @Override
    public void shareResultCallBack(int result) {
        if(result==4){//我的圈子
            String recordPath = null;
            if(mAudioFile!=null){
                recordPath = mAudioFile.getPath();
            }
            DialogUtil.shareCircle(this,mMusicId,mMusicName,mCountSing,mMusicCorverUrl,recordPath);
        }
    }

    /**
     * 发布是否展示在个人主页
     * isShow是 1 否 2
     */
    private void publishIsShowPersonal(String isShow){
        saveDefaultPic();
        HttpMethod.kojiPreservation(this,this,mMusicId,isShow,mAudioFile,new File(mMusicBgPath));
    }

    @Override
    protected void onhttpSuccess(String data, int method) {
        super.onhttpSuccess(data, method);
        if(method==HTTP_KOJI_PRESERVATION){
            Response response = GsonUtil.GsonToBean(data,Response.class);
            if(response!=null){
                if(mPublishType!=2){
                    ToastUtil.makeLongText(this,"作品已发布完成");
                }
                isPublishSing = true;
                mPublishSingId = response.getSing_id();
                if(mPublishType==2){//分享前发布
                    mLinkUrl = String.format(HttpMethod.SHARE_USERKOJI,mPublishSingId);
                    //分享弹框
                    DialogUtil.showShareMusicDialog(this,this);
                }
            }
        }
    }

    private void getIntentData(){
        Intent intent = getIntent();
        mMusicId = intent.getStringExtra("musicId");//伴奏id
        mMusicCorverUrl = intent.getStringExtra("coverUrl");//伴奏音乐封面图片
        mMusicName = intent.getStringExtra("musicName");//伴奏音乐名称
        mCountSing = intent.getStringExtra("countSing");//演唱人数
        mMusicUrl = intent.getStringExtra("musicUrl");//伴奏音乐
        mOriginalMusicUrl = intent.getStringExtra("originalMusicUrl");//原唱音乐
        mMusicLrcUrl = intent.getStringExtra("musicLrcUrl");//歌词url
        mArtistName = intent.getStringExtra("artistName");//作者
    }

    /**
     *
     * @param context
     * @param musicId
     * 伴奏id
     * @param coverUrl
     * 伴奏音乐封面图片
     * @param musicName
     * 伴奏音乐名称
     * @param countSing
     * 演唱人数
     * @param musicUrl
     * 伴奏音乐
     * @param originalMusicUrl
     * 原唱音乐
     * @param musicLrcUrl
     * 歌词url
     * @param artistName
     * 作者
     */
    public static void startActivity(Context context,String musicId,String coverUrl,String musicName,String countSing,String musicUrl,String originalMusicUrl,String musicLrcUrl,String artistName){
        Intent intent = new Intent(context,RecordMusicActivity.class);
        intent.putExtra("musicId",musicId);
        intent.putExtra("coverUrl",coverUrl);
        intent.putExtra("musicName",musicName);
        intent.putExtra("countSing",countSing);
        intent.putExtra("musicUrl",musicUrl);
        intent.putExtra("originalMusicUrl",originalMusicUrl);
        intent.putExtra("musicLrcUrl",musicLrcUrl);
        intent.putExtra("artistName",artistName);
        context.startActivity(intent);
    }
}
